const resizeEvents = []

window.addEventListener('resize', function () {
  resizeEvents.forEach(fn => {
    fn()
  })
})

export function addResizeEvent (fn) {
  resizeEvents.push(fn)
}

export function removeResizeEvent (fn) {
  const index = resizeEvents.indexOf(fn)
  if (index > -1) {
    resizeEvents.splice(index, 1)
  }
}

export function triggerResizeEvent () {
  resizeEvents.forEach(fn => {
    fn()
  })
}
